<?php
/*
	处理内容
*/

class Article extends Main{
	
	//取得文章内容
	function articles($article_id){
		$sql = "select a.id,a.typeid,a.title,a.writer,a.source,a.pubdate as time,a.keywords,a.description,a.litpic as img,ad.body from  archives as a inner join  addonarticle as ad on a.id=ad.aid where a.id='".$article_id."';";
		$data = $GLOBALS['mysql']->getAll($sql);
		if(!empty($data[0]))
		{
			$data = $data[0];
			
			$data['body'] = preg_replace("/\.\.\//","./",$data['body']);
			$data['img']  = preg_replace("/\.\.\//","./",$data['img']); 
			$data['time'] = date("Y-m-d H:i:s",	$data['time']);
			$data['url']  = $this->buildUri($data['title'],$article_id,'article');
			return $data;
		}
		else
		{
			$main->msg('数据错误！','index.php');
		}
	
	}

	//删除文章
	function delArticle($a_id){
		$sql1 = "delete from archives where id='".$a_id."';";
		$res1 = mysql_query($sql1);
		$sql2 = "delete from addonarticle where aid='".$a_id."'";
		$res2 = mysql_query($sql2);
		
		return ($res1 && $res2);
	}

} 

?>